package br.com.jpoker.common.ui.action;

import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;

import br.com.jpoker.model.Card;
import br.com.jpoker.model.Table;

/**
 *
 */
public class DrawFlopAction{
	
	private Timer timer;
	private Table table;
	private ArrayList<Card> cardsList;
	int currentIndex = 0;
	
	public DrawFlopAction(Table table, ArrayList<Card> cardsList) {
		this.table = table;
		this.cardsList = cardsList;
		timer = new Timer();
		timer.scheduleAtFixedRate(new DrawCardsTask(), 0, 1 * 200); 
	}

	class DrawCardsTask extends TimerTask {
		public void run() {
			if(currentIndex == 3){
				timer.cancel();
				return;
			}
			table.getFlopHolderCards()[currentIndex].setIcon(cardsList.get(currentIndex).getImage());
			currentIndex++;
		}
	}

}